/**
 * [pageDes login.html]
 * @description  admin后台的用户登录页面
 * @return {[type]}      [description]
 */
module.exports = function( oApp ){
    
    let app      =   oApp.app,            // App对象,即整个应用程序对象
        Config   =   app.get('config'),   // 一些web配置信息
        psfx     =   Config.psfx,         // 页面访问的扩展/后缀名 .html
        isfx     =   Config.isfx,         // 接口访问的扩展/后缀名 .json
        helper   =   oApp.helper,         // 辅助函数库
        proxy    =   oApp.proxy;          // http 服务代理
    
    // 模板界面的引用返回
    app.get('/login' + psfx, function( request, response ){
        
        /*
        helper.common.sync( [function(){
            Model.searchTest( this, response, 'd1' );
        }, function(){
            Model.searchTest2( this, response, 'd2' );
        }] )
        .then(function( v ){
            
            response.render('screen/login', {
                
                layout: app.locals.layout,
                title: '一家说后台用户登录',
                Model: {
                    userName: request.session.user,
                    mp3: response.locals.d2
                }
                
            })
            
        })
        */
        
        /*
        helper.turnhost.setup({
            
            request: request,
            type: 'post',
            url: '/loushus/findOneApp',
            callback: function( data, size ){
                
                response.render('screen/login', {
            
                    layout: app.locals.layout,
                    title: '一家说后台用户登录',
                    Model: {
                        userName: request.session.user,
                        proxy: data.content
                    }
                    
                })
                
            }
            
        })
        */
        
        response.render('screen/login', {
            
            layout: app.locals.layout,
            title: '一家说后台用户登录',
            Model: {}
            
        })
        
    })
    
    // 用户登录接口
    // 调用java服务一共有两款方法，一款是来自第三方github上的express包，另外一款是我自己写的。两款都可以用
    /*
    // 调用java接口数据
    proxy( '/userLogin' + isfx, '/loushus/findOneApp' )
    // 自己这边Node接口
    .post('/userLogin' + isfx, function( request, response ){
        
        response.send( response.locals.proxyResData );
        
    })
    */
   app.post('/userLogin' + isfx, function( request, response ){
        
        // 自己写的helper 调用java接口数据
        helper.turnhost.setup({
            request: request,
            type: 'post',
            url: '/loushus/findOneApp',
            callback: function( data, size ){
                console.log(data.content);
            }
        })
        response.send( {a:345} );
        
    })
    
}